package WaiBao;

import java.util.Arrays;

public class HuYaTing {
    public static void main(String[] args) {
        String[] name = {"张德玉(班长)", "李浩楠(副班长)", "小李(学习委员)", "王志强(团支书)", "王大平", "长大崔", "王崔子", "李浩东", "王培春", "王桂玲", "王多陪", "王绍培",
                "李志豪", "刘志武", "张宇星", "章鱼", "山鸡", "陈浩南", "龙达", "李杨凯", "李存勖", "王多鱼", "张德发", "周二磊", "王廷安", "毛泽勋", "刘保国", "杨荣耀",
                "杨颖", "胡雅婷(文艺委员)"};//考生本人:胡雅婷(文艺委员)
        int[] age = {21, 21, 20, 21, 19, 21, 21,21,20, 20, 18, 18, 21, 20, 21, 20, 18, 19, 18, 20, 19, 19, 20, 21, 20, 18, 20, 20, 21, 20};//考生年龄：20

        double[] wusong1 = {79, 74, 85, 80, 81, 64, 78, 99, 60, 84, 94, 87, 85, 79, 74, 68, 69, 79, 96, 88, 92, 91, 95, 85, 75, 74, 76, 89, 88, 95};
        double[] wusong2 = {84, 85, 84, 65, 78, 87, 77, 69, 60, 80, 94, 67, 74, 75, 85, 65, 86, 79, 66, 78, 85, 71, 84, 85, 75, 80, 75, 78, 87, 96};
        double[] wusong3 = {86, 84, 71, 65, 89, 75, 69, 69, 80, 60, 93, 87, 85, 85, 65, 68, 89, 79, 96, 63, 92, 81, 95, 85, 76, 84, 73, 78, 78, 95};

        double fushi1;//代表每个学生的总分
        double fushi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            fushi1 = wusong1[i] + wusong2[i] +wusong3[i];
//            fushi2 = (fushi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + fushi1);
//            System.out.println(name[i] + "的平均分为:" + fushi2);
//        }

        double gongji1 = 0, gongji2 = 0;
        double[] juhua = new double[30];
//        for (int i = 0; i < 30; i++) {
//            gongji1 =wusong1[i] + wusong2[i] + wusong3[i];
//            gongji2 = (gongji1 * 1.0) / 3;
//            juhua[i] = gongji2;
//        }
//
//        for (int i = 0; i < juhua.length - 1; i++) {
//            for (int j = 0; j <juhua.length - i - 1; j++) {
//                if (juhua[j] < juhua[j + 1]) {
//                    double temp = juhua[j];
//                    juhua[j] =juhua[j + 1];
//                    juhua[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(juhua[i]);
//        }



        double mianxie1 = 0,mianxie2 = 0, mianxie3 = 0;//计算每门课的平均分
        double crocus1 = 0, crocus2 = 0, crocus3 = 0;//计算每门课标准差
        double yingyu1 = 0, yingyu2 = 0, yingyu3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <wusong1.length; i++) {
            sum2+=wusong1[i];
        }
        mianxie1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+mianxie1);
        double Sum = 0;
        for (int i = 0; i < wusong2.length; i++) {
            Sum+=wusong2[i];
        }
        mianxie2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+mianxie2);
        double sum = 0;
        for (int i = 0; i <wusong3.length; i++) {
            sum+=wusong3[i];
        }
        mianxie3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+mianxie3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < wusong1.length; i++) {
            c1+= (wusong1[i] -mianxie1)*(wusong1[i] - mianxie1);
        }
        crocus1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ crocus1);

        for (int i = 0; i <wusong2.length; i++) {
            c2+= (wusong2[i] -mianxie2)*(wusong2[i] - mianxie2);
        }
        crocus2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ crocus2);

        for (int i = 0; i < wusong3.length; i++) {
            c3+= (wusong3[i] - mianxie3)*(wusong3[i] -mianxie3);
        }
        crocus3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ crocus3);
//////
        Arrays.sort(wusong1);
        Arrays.sort(wusong2);
        Arrays.sort(wusong3);
        yingyu1 =( wusong1[14]+wusong1[15])*1.0/2;
        yingyu2 =( wusong2[14]+wusong2[15])*1.0/2;
        yingyu3 =( wusong3[14]+wusong3[15])*1.0/2;
        System.out.println("分析化学的中位数为:"+yingyu1);
        System.out.println("线性代数的中位数为:"+yingyu2);
        System.out.println("有机化学学的中位数为:"+yingyu3);



    }
}
